package com.hbpu.encap.reflection;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Homework02 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
//        File file = new File("D:\\aa.txt");
//        file.createNewFile();
//        Class<?> aClass = Class.forName(file);
        Class<?> aClass = Class.forName("java.io.File");
        Object o = aClass.getDeclaredConstructor(String.class).newInstance("D:\\aa.txt");
        Method createNewFile = aClass.getMethod("createNewFile");
        createNewFile.invoke(o);
        Constructor<?>[] declaredConstructors = aClass.getDeclaredConstructors();
        for (Constructor<?> declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }
    }
}
